package com.bestdreamer.exception;

public class Demo1Run2 {

    public static void main(String[] args) {
        Demo1MyThread thread = new Demo1MyThread();
        thread.setName("线程 A");
        thread.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
            @Override
            public void uncaughtException(Thread t, Throwable e) {
                System.out.println("线程 ：" + t.getName() + "出现了异常：" + e.getMessage());
            }
        });
        thread.start();

        Demo1MyThread thread1 = new Demo1MyThread();
        thread1.setName("线程 B");
        thread1.start();
    }
}
